﻿<UserControl x:Class="myManga.UI.AdvImage"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
             xmlns:baka="clr-namespace:BakaBox.Controls;assembly=BakaBox"
             xmlns:converter="clr-namespace:myManga.UI.Code"
             SnapsToDevicePixels="True"
             Background="Black" 
             Focusable="False"
             DataContext="{Binding RelativeSource={RelativeSource Self}}">
    <UserControl.Resources>
        <Storyboard 
            x:Key="FadeImage"
            SpeedRatio="2.5">
            <DoubleAnimation 
                Storyboard.TargetName="ImageScroll"
                Storyboard.TargetProperty="Opacity"/>
            <DoubleAnimation 
                Storyboard.TargetName="BlurEffect"
                Storyboard.TargetProperty="Radius"/>
        </Storyboard>
        <converter:BorderClipConverter x:Key="BorderClipper"/>
    </UserControl.Resources>
    <Grid>
        <TextBlock 
            x:Name="DebugText"
            Grid.ZIndex="99" 
            Foreground="Red" 
            FontSize="21" 
            Margin="0,0,0,0"
            HorizontalAlignment="Left"
            VerticalAlignment="Top"
            IsHitTestVisible="False"/>
        <ScrollViewer 
            Style="{StaticResource MetroScrollViewer}"
            Opacity="0" 
            x:Name="ImageScroll"
            HorizontalScrollBarVisibility="Auto" 
            VerticalScrollBarVisibility="Auto" 
            PanningMode="Both" 
            Background="Black">
            <Border 
                x:Name="ImageClip"
                Background="Black" 
                CornerRadius="4"
                Margin="5"
                HorizontalAlignment="Center" 
                VerticalAlignment="Center" 
                SnapsToDevicePixels="True"
                Focusable="False">
                <Border.Effect>
                    <BlurEffect x:Name="BlurEffect"/>
                </Border.Effect>
                <Border.Clip>
                    <MultiBinding Converter="{StaticResource BorderClipper}">
                        <Binding Path="ActualWidth" RelativeSource="{RelativeSource Self}"/>
                        <Binding Path="ActualHeight" RelativeSource="{RelativeSource Self}"/>
                        <Binding Path="CornerRadius" RelativeSource="{RelativeSource Self}"/>
                    </MultiBinding>
                </Border.Clip>
                <baka:StreamImage 
                    x:Name="ImageStream">
                    <baka:StreamImage.LayoutTransform>
                        <ScaleTransform 
                            ScaleX="{Binding Path=ImageZoom, Mode=OneWay}" 
                            ScaleY="{Binding Path=ImageZoom, Mode=OneWay}"/>
                    </baka:StreamImage.LayoutTransform>
                </baka:StreamImage>
            </Border>
        </ScrollViewer>
    </Grid>
</UserControl>
